/*
 * PawsView.java
 */

package paws.gui;

import paws.core.*;
import scala.collection.immutable.List;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;

import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
// import java.awt.event.MouseEvent ;
// import java.awt.event.MouseListener ;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class PawsView extends FrameView {
    public PawsView(SingleFrameApplication app) {
        super(app);

        initComponents();
        initCustomComponents() ; //Allows for user added components

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(true);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        progressBar.setVisible(true);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    // progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = PawsApp.getApplication().getMainFrame();
            aboutBox = new PawsAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        PawsApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        displayTabbedPane = new javax.swing.JTabbedPane();
        nodemapPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        graphPane = new javax.swing.JTabbedPane();
        reiliabilityTab = new javax.swing.JPanel();
        powerTab = new javax.swing.JPanel();
        delayTab = new javax.swing.JPanel();
        runButton = new javax.swing.JButton();
        resetButton = new javax.swing.JButton();
        buttonPanel = new javax.swing.JPanel();
        selectButton = new javax.swing.JButton();
        uniformButton = new javax.swing.JButton();
        singleNodeButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        deselectButton = new javax.swing.JButton();
        nonUniformButton = new javax.swing.JButton();
        cursorInfoPanel = new javax.swing.JPanel();
        stateLabel = new javax.swing.JLabel();
        startNodeButton = new javax.swing.JRadioButton();
        midNodeButton = new javax.swing.JRadioButton();
        endNodeButton = new javax.swing.JRadioButton();
        nodeTypeLabel = new javax.swing.JLabel();
        densityLabel = new javax.swing.JLabel();
        densitySpinner = new javax.swing.JSpinner();
        jLabel1 = new javax.swing.JLabel();
        clusterCountLabel = new javax.swing.JLabel();
        nodesInClusterLabel = new javax.swing.JLabel();
        clusterRadiusLabel = new javax.swing.JLabel();
        clusterSpinner = new javax.swing.JSpinner();
        nodesInClusterSpinner = new javax.swing.JSpinner();
        clusterDensitySpinner = new javax.swing.JSpinner();
        testLabel = new javax.swing.JLabel();
        nodeCountDisplay = new javax.swing.JLabel();
        cursorLocationLabel = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        typeButtonGroup = new javax.swing.ButtonGroup();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(600, 379));

        displayTabbedPane.setName("displayTabbedPane"); // NOI18N

        nodemapPanel.setName("nodemapPanel"); // NOI18N
        nodemapPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nodemapPanelMouseClicked(evt);
            }
        });
        nodemapPanel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                nodemapPanelMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                nodemapPanelMouseMoved(evt);
            }
        });

        javax.swing.GroupLayout nodemapPanelLayout = new javax.swing.GroupLayout(nodemapPanel);
        nodemapPanel.setLayout(nodemapPanelLayout);
        nodemapPanelLayout.setHorizontalGroup(
            nodemapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 586, Short.MAX_VALUE)
        );
        nodemapPanelLayout.setVerticalGroup(
            nodemapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 417, Short.MAX_VALUE)
        );

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(paws.gui.PawsApp.class).getContext().getResourceMap(PawsView.class);
        displayTabbedPane.addTab(resourceMap.getString("nodemapPanel.TabConstraints.tabTitle"), nodemapPanel); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        graphPane.setName("graphPane"); // NOI18N

        reiliabilityTab.setName("reiliabilityTab"); // NOI18N

        javax.swing.GroupLayout reiliabilityTabLayout = new javax.swing.GroupLayout(reiliabilityTab);
        reiliabilityTab.setLayout(reiliabilityTabLayout);
        reiliabilityTabLayout.setHorizontalGroup(
            reiliabilityTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 581, Short.MAX_VALUE)
        );
        reiliabilityTabLayout.setVerticalGroup(
            reiliabilityTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 389, Short.MAX_VALUE)
        );

        graphPane.addTab(resourceMap.getString("reiliabilityTab.TabConstraints.tabTitle"), reiliabilityTab); // NOI18N

        powerTab.setName("powerTab"); // NOI18N

        javax.swing.GroupLayout powerTabLayout = new javax.swing.GroupLayout(powerTab);
        powerTab.setLayout(powerTabLayout);
        powerTabLayout.setHorizontalGroup(
            powerTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 581, Short.MAX_VALUE)
        );
        powerTabLayout.setVerticalGroup(
            powerTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 389, Short.MAX_VALUE)
        );

        graphPane.addTab(resourceMap.getString("powerTab.TabConstraints.tabTitle"), powerTab); // NOI18N

        delayTab.setName("delayTab"); // NOI18N

        javax.swing.GroupLayout delayTabLayout = new javax.swing.GroupLayout(delayTab);
        delayTab.setLayout(delayTabLayout);
        delayTabLayout.setHorizontalGroup(
            delayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 581, Short.MAX_VALUE)
        );
        delayTabLayout.setVerticalGroup(
            delayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 389, Short.MAX_VALUE)
        );

        graphPane.addTab(resourceMap.getString("delayTab.TabConstraints.tabTitle"), delayTab); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(graphPane)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(graphPane, javax.swing.GroupLayout.DEFAULT_SIZE, 417, Short.MAX_VALUE)
        );

        displayTabbedPane.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        runButton.setText(resourceMap.getString("runButton.text")); // NOI18N
        runButton.setName("runButton"); // NOI18N
        runButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                runButtonMouseClicked(evt);
            }
        });

        resetButton.setText(resourceMap.getString("resetButton.text")); // NOI18N
        resetButton.setName("resetButton"); // NOI18N

        buttonPanel.setName("buttonPanel"); // NOI18N

        selectButton.setText(resourceMap.getString("selectButton.text")); // NOI18N
        selectButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        selectButton.setName("selectButton"); // NOI18N
        selectButton.setPreferredSize(new java.awt.Dimension(45, 5));
        selectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                selectButtonMouseClicked(evt);
            }
        });

        uniformButton.setText(resourceMap.getString("uniformButton.text")); // NOI18N
        uniformButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        uniformButton.setName("uniformButton"); // NOI18N
        uniformButton.setPreferredSize(new java.awt.Dimension(45, 5));
        uniformButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                uniformButtonMouseClicked(evt);
            }
        });

        singleNodeButton.setText(resourceMap.getString("singleNodeButton.text")); // NOI18N
        singleNodeButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        singleNodeButton.setName("singleNodeButton"); // NOI18N
        singleNodeButton.setPreferredSize(new java.awt.Dimension(45, 5));
        singleNodeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                singleNodeButtonMouseClicked(evt);
            }
        });

        deleteButton.setText(resourceMap.getString("deleteButton.text")); // NOI18N
        deleteButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        deleteButton.setName("deleteButton"); // NOI18N
        deleteButton.setPreferredSize(new java.awt.Dimension(45, 5));
        deleteButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                deleteButtonMouseClicked(evt);
            }
        });

        deselectButton.setText(resourceMap.getString("deselectButton.text")); // NOI18N
        deselectButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        deselectButton.setName("deselectButton"); // NOI18N
        deselectButton.setPreferredSize(new java.awt.Dimension(45, 5));
        deselectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                deselectButtonMouseClicked(evt);
            }
        });

        nonUniformButton.setText(resourceMap.getString("nonUniformButton.text")); // NOI18N
        nonUniformButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        nonUniformButton.setName("nonUniformButton"); // NOI18N
        nonUniformButton.setPreferredSize(new java.awt.Dimension(45, 5));
        nonUniformButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nonUniformButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout buttonPanelLayout = new javax.swing.GroupLayout(buttonPanel);
        buttonPanel.setLayout(buttonPanelLayout);
        buttonPanelLayout.setHorizontalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(singleNodeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(selectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(buttonPanelLayout.createSequentialGroup()
                        .addComponent(deselectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(nonUniformButton, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(buttonPanelLayout.createSequentialGroup()
                        .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(uniformButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(75, Short.MAX_VALUE))
        );
        buttonPanelLayout.setVerticalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(selectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(deselectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(nonUniformButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(singleNodeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(uniformButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        cursorInfoPanel.setName("cursorInfoPanel"); // NOI18N

        stateLabel.setText(resourceMap.getString("stateLabel.text")); // NOI18N
        stateLabel.setName("stateLabel"); // NOI18N

        typeButtonGroup.add(startNodeButton);
        startNodeButton.setText(resourceMap.getString("startNodeButton.text")); // NOI18N
        startNodeButton.setName("startNodeButton"); // NOI18N
        startNodeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                startNodeButtonMouseClicked(evt);
            }
        });
        startNodeButton.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                startNodeButtonItemStateChanged(evt);
            }
        });

        typeButtonGroup.add(midNodeButton);
        midNodeButton.setSelected(true);
        midNodeButton.setText(resourceMap.getString("midNodeButton.text")); // NOI18N
        midNodeButton.setName("midNodeButton"); // NOI18N
        midNodeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                midNodeButtonMouseClicked(evt);
            }
        });

        typeButtonGroup.add(endNodeButton);
        endNodeButton.setText(resourceMap.getString("endNodeButton.text")); // NOI18N
        endNodeButton.setName("endNodeButton"); // NOI18N
        endNodeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                endNodeButtonMouseClicked(evt);
            }
        });

        nodeTypeLabel.setText(resourceMap.getString("nodeTypeLabel.text")); // NOI18N
        nodeTypeLabel.setName("nodeTypeLabel"); // NOI18N

        densityLabel.setText(resourceMap.getString("densityLabel.text")); // NOI18N
        densityLabel.setName("densityLabel"); // NOI18N

        densitySpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 2000, 1));
        densitySpinner.setName("densitySpinner"); // NOI18N
        densitySpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                densitySpinnerStateChanged(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        clusterCountLabel.setText(resourceMap.getString("clusterCountLabel.text")); // NOI18N
        clusterCountLabel.setName("clusterCountLabel"); // NOI18N

        nodesInClusterLabel.setText(resourceMap.getString("nodesInClusterLabel.text")); // NOI18N
        nodesInClusterLabel.setName("nodesInClusterLabel"); // NOI18N

        clusterRadiusLabel.setText(resourceMap.getString("clusterRadiusLabel.text")); // NOI18N
        clusterRadiusLabel.setName("clusterRadiusLabel"); // NOI18N

        clusterSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
        clusterSpinner.setName("clusterSpinner"); // NOI18N
        clusterSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                clusterSpinnerStateChanged(evt);
            }
        });

        nodesInClusterSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 100, 1));
        nodesInClusterSpinner.setName("nodesInClusterSpinner"); // NOI18N
        nodesInClusterSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                nodesInClusterSpinnerStateChanged(evt);
            }
        });

        clusterDensitySpinner.setName("clusterDensitySpinner"); // NOI18N
        clusterDensitySpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                clusterDensitySpinnerStateChanged(evt);
            }
        });

        testLabel.setText(resourceMap.getString("testLabel.text")); // NOI18N
        testLabel.setName("testLabel"); // NOI18N

        javax.swing.GroupLayout cursorInfoPanelLayout = new javax.swing.GroupLayout(cursorInfoPanel);
        cursorInfoPanel.setLayout(cursorInfoPanelLayout);
        cursorInfoPanelLayout.setHorizontalGroup(
            cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addComponent(stateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                                .addComponent(startNodeButton)
                                .addGap(6, 6, 6)
                                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nodeTypeLabel)
                                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                                        .addComponent(midNodeButton)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(endNodeButton))))
                            .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                                .addComponent(densityLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jLabel1))
                                    .addComponent(densitySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nodesInClusterLabel)
                            .addComponent(clusterCountLabel)
                            .addComponent(clusterRadiusLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(clusterSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                            .addComponent(nodesInClusterSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                            .addComponent(clusterDensitySpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)))
                    .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(testLabel)))
                .addContainerGap())
        );
        cursorInfoPanelLayout.setVerticalGroup(
            cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cursorInfoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(stateLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(nodeTypeLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(startNodeButton)
                    .addComponent(midNodeButton)
                    .addComponent(endNodeButton))
                .addGap(18, 18, 18)
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(densityLabel)
                    .addComponent(densitySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(clusterCountLabel)
                    .addComponent(clusterSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nodesInClusterLabel)
                    .addComponent(nodesInClusterSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cursorInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(clusterRadiusLabel)
                    .addComponent(clusterDensitySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addComponent(testLabel)
                .addGap(40, 40, 40))
        );

        nodeCountDisplay.setText(resourceMap.getString("nodeCountDisplay.text")); // NOI18N
        nodeCountDisplay.setName("nodeCountDisplay"); // NOI18N

        cursorLocationLabel.setText(resourceMap.getString("cursorLocationLabel.text")); // NOI18N
        cursorLocationLabel.setName("cursorLocationLabel"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(nodeCountDisplay)
                        .addGap(18, 18, 18)
                        .addComponent(cursorLocationLabel))
                    .addComponent(buttonPanel, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(cursorInfoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addGap(115, 115, 115)
                        .addComponent(runButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(resetButton))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(displayTabbedPane)))
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                        .addComponent(displayTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(runButton)
                            .addComponent(resetButton)))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cursorInfoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nodeCountDisplay)
                            .addComponent(cursorLocationLabel))))
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        newMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        newMenuItem.setText(resourceMap.getString("newMenuItem.text")); // NOI18N
        newMenuItem.setName("newMenuItem"); // NOI18N
        newMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newMenuItemMouseClicked(evt);
            }
        });
        newMenuItem.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                newMenuItemItemStateChanged(evt);
            }
        });
        newMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(newMenuItem);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(paws.gui.PawsApp.class).getContext().getActionMap(PawsView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 920, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 750, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void initCustomComponents() //initialize user added components
    {
        cursorState = new paws.gui.CursorMode() ;
        simRunning = false;

        //initialization of the nodeCanvas for drawing

        nodeCanvas = new PawsCanvas() ;
        nodeCanvas.setName("nodeCanvas"); // NOI18N

        javax.swing.GroupLayout nodeCanvasLayout = new javax.swing.GroupLayout(nodeCanvas);
        nodeCanvas.setLayout(nodeCanvasLayout);
        nodeCanvasLayout.setHorizontalGroup(
            nodeCanvasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 607, Short.MAX_VALUE)
        );
        nodeCanvasLayout.setVerticalGroup(
            nodeCanvasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 407, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout nodemapPanelLayout = new javax.swing.GroupLayout(nodemapPanel);
        nodemapPanel.setLayout(nodemapPanelLayout);
        nodemapPanelLayout.setHorizontalGroup(
            nodemapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(nodemapPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(nodeCanvas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        nodemapPanelLayout.setVerticalGroup(
            nodemapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(nodemapPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(nodeCanvas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        //init nodeCanvas Listeners
         nodeCanvas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nodeCanvasMouseClicked(evt);
            }
         }) ;

          nodeCanvas.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                nodeCanvasMouseMoved(evt);
            }
        });


    }

   

    private void runButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runButtonMouseClicked
        if(simRunning)
          return;
//        {
//            progressBar.setIndeterminate(false);
//            runButton.setText("Run");
//        }
//        else
//        {
        progressBar.setVisible(true) ;
        progressBar.setIndeterminate(true);
        runButton.setText("Running");
        runButton.setEnabled(false);
        simRunning = true;            
//        }
        Runnable r = new Runnable() {
          public void run() {
            Simulation sim = new Simulation();            
            Set<Node> nodes = nodeCanvas.getNodes();
            NodeParameters np = new NodeParameters();
            int id = 0;
            for(Node gn: nodes) {
              paws.core.Node n = new paws.core.Node(sim, np);
              n.setLocation(gn.getX(), gn.getY());
              n.setID(id);
              id++;
              switch(gn.getType()) {
                case Start:
                  n.setNodeType(NodeType.Source());
                  break;
                case Intermediary:
                  n.setNodeType(NodeType.Intermediary());
                  break;
                case End:
                  n.setNodeType(NodeType.Destination());
                  break;
              }
              sim.addNode(n);
            }
            System.out.println("Starting simulation!");
            sim.start();
            
            while(sim.isRunning())
              Thread.yield();
            
            List<Data> data = sim.getData();
            for(List<Data> d = data; !d.isEmpty(); d = (List<Data>)d.tail()) {
              Data item = d.head();
              System.out.println(
                  "t="  + item.timestamp() +
                  ";p=" + item.power() +
                  ";r=" + item.reliability() +
                  ";d=" + item.delay()
              );
            }
            
            runButton.setText("Run");
            runButton.setEnabled(true);
            progressBar.setIndeterminate(false);
            simRunning = false;
          }
        };
        new Thread(r).start();
    }//GEN-LAST:event_runButtonMouseClicked

    //Mouse clicks on the buttons, changes cursor State
    private void selectButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_selectButtonMouseClicked

        cursorState.setState(CursorMode.mode.Select) ;
        nodeCanvas.setState(cursorState) ;

        stateLabel.setText("Select");

    }//GEN-LAST:event_selectButtonMouseClicked

    private void uniformButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_uniformButtonMouseClicked
        cursorState.setState(CursorMode.mode.Uniform) ;

        stateLabel.setText("Uniform");
        nodeCanvas.setState(cursorState) ;
    }//GEN-LAST:event_uniformButtonMouseClicked

    private void nonUniformButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nonUniformButtonMouseClicked
       cursorState.setState(CursorMode.mode.NonUniform) ;
       nodeCanvas.setState(cursorState) ;
       stateLabel.setText("NonUniform");
    }//GEN-LAST:event_nonUniformButtonMouseClicked

    private void singleNodeButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_singleNodeButtonMouseClicked

        cursorState.setState(CursorMode.mode.Single) ;
        nodeCanvas.setState(cursorState) ;
        
        stateLabel.setText("Single");

    }//GEN-LAST:event_singleNodeButtonMouseClicked

    private void nodemapPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nodemapPanelMouseClicked
        
    }//GEN-LAST:event_nodemapPanelMouseClicked

    private void nodemapPanelMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nodemapPanelMouseMoved
        nodeCountDisplay.setText("Node Count: " + nodeCanvas.getNodeCount());
        Point p = nodeCanvas.getCursorLocation();
        String text = (p != null) ?
            "( " + p.x + ", " + p.y + ")" : "";
        cursorLocationLabel.setText(text);
    }//GEN-LAST:event_nodemapPanelMouseMoved

    private void deleteButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deleteButtonMouseClicked
        nodeCanvas.deleteNodes(); 
    }//GEN-LAST:event_deleteButtonMouseClicked

    private void startNodeButtonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_startNodeButtonItemStateChanged
      
    }//GEN-LAST:event_startNodeButtonItemStateChanged

    private void startNodeButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startNodeButtonMouseClicked
         if (startNodeButton.isSelected())
            nodeCanvas.setNodeType(Node.Type.Start);
    }//GEN-LAST:event_startNodeButtonMouseClicked

    private void midNodeButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_midNodeButtonMouseClicked

        if (midNodeButton.isSelected())
            nodeCanvas.setNodeType(Node.Type.Intermediary);
    }//GEN-LAST:event_midNodeButtonMouseClicked

    private void endNodeButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_endNodeButtonMouseClicked

        if(endNodeButton.isSelected())
            nodeCanvas.setNodeType(Node.Type.End) ;
    }//GEN-LAST:event_endNodeButtonMouseClicked

    private void deselectButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deselectButtonMouseClicked
        nodeCanvas.deselectNodes(); 
    }//GEN-LAST:event_deselectButtonMouseClicked

    private void nodemapPanelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nodemapPanelMouseDragged
        cursorLocationLabel.setText("( " + nodeCanvas.getCursorLocation().x + ", " + nodeCanvas.getCursorLocation().y + ")");

    }//GEN-LAST:event_nodemapPanelMouseDragged

    private void densitySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_densitySpinnerStateChanged
        
        try
        {
                densitySpinner.commitEdit() ;
        }
        catch (java.text.ParseException pe)
        {
            densitySpinner.setValue(1);
        }
        
        nodeCanvas.setDensity((Integer)densitySpinner.getValue());
    }//GEN-LAST:event_densitySpinnerStateChanged

    private void clusterSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_clusterSpinnerStateChanged
        // TODO add your handling code here:
        nodeCanvas.setClusterProperties((Integer)clusterSpinner.getValue(), (Integer)nodesInClusterSpinner.getValue(), (Integer)clusterDensitySpinner.getValue()) ;
    }//GEN-LAST:event_clusterSpinnerStateChanged

    private void nodesInClusterSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nodesInClusterSpinnerStateChanged
        // TODO add your handling code here:
        nodeCanvas.setClusterProperties((Integer)clusterSpinner.getValue(), (Integer)nodesInClusterSpinner.getValue(), (Integer)clusterDensitySpinner.getValue()) ;
    }//GEN-LAST:event_nodesInClusterSpinnerStateChanged

    private void clusterDensitySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_clusterDensitySpinnerStateChanged
        // TODO add your handling code here:
        nodeCanvas.setClusterProperties((Integer)clusterSpinner.getValue(), (Integer)nodesInClusterSpinner.getValue(), (Integer)clusterDensitySpinner.getValue()) ;
        testLabel.setText(nodeCanvas.getClusterStats());
    }//GEN-LAST:event_clusterDensitySpinnerStateChanged

    private void newMenuItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newMenuItemMouseClicked
        // TODO add your handling code here:
        
    }//GEN-LAST:event_newMenuItemMouseClicked

    private void newMenuItemItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_newMenuItemItemStateChanged
        nodeCanvas = new PawsCanvas() ;        // TODO add your handling code here:
    }//GEN-LAST:event_newMenuItemItemStateChanged

    private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newMenuItemActionPerformed
        // TODO add your handling code here:
        nodeCanvas.clearAllNodes();
    }//GEN-LAST:event_newMenuItemActionPerformed

    private void nodeCanvasMouseMoved(java.awt.event.MouseEvent evt){

        try
        {
        cursorLocationLabel.setText("( " + nodeCanvas.getCursorLocation().x + ", " + nodeCanvas.getCursorLocation().y + ")");
        }
        catch(NullPointerException npe)
        {

        }
    }
    private void nodeCanvasMouseClicked(java.awt.event.MouseEvent evt){
        nodeCountDisplay.setText("Node Count: " + nodeCanvas.getNodeCount());
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JLabel clusterCountLabel;
    private javax.swing.JSpinner clusterDensitySpinner;
    private javax.swing.JLabel clusterRadiusLabel;
    private javax.swing.JSpinner clusterSpinner;
    private javax.swing.JPanel cursorInfoPanel;
    private javax.swing.JLabel cursorLocationLabel;
    private javax.swing.JPanel delayTab;
    private javax.swing.JButton deleteButton;
    private javax.swing.JLabel densityLabel;
    private javax.swing.JSpinner densitySpinner;
    private javax.swing.JButton deselectButton;
    private javax.swing.JTabbedPane displayTabbedPane;
    private javax.swing.JRadioButton endNodeButton;
    private javax.swing.JTabbedPane graphPane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JRadioButton midNodeButton;
    private javax.swing.JMenuItem newMenuItem;
    private javax.swing.JLabel nodeCountDisplay;
    private javax.swing.JLabel nodeTypeLabel;
    protected javax.swing.JPanel nodemapPanel;
    private javax.swing.JLabel nodesInClusterLabel;
    private javax.swing.JSpinner nodesInClusterSpinner;
    private javax.swing.JButton nonUniformButton;
    private javax.swing.JPanel powerTab;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JPanel reiliabilityTab;
    private javax.swing.JButton resetButton;
    private javax.swing.JButton runButton;
    private javax.swing.JButton selectButton;
    private javax.swing.JButton singleNodeButton;
    private javax.swing.JRadioButton startNodeButton;
    private javax.swing.JLabel stateLabel;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JLabel testLabel;
    private javax.swing.ButtonGroup typeButtonGroup;
    private javax.swing.JButton uniformButton;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;

    //User defined variables
    private paws.gui.CursorMode cursorState ;
    private PawsCanvas nodeCanvas;
    private int density ;
    private boolean simRunning;
}
